<%@page import="cfs.databean.FundPriceHistory"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.sql.Date"%>
<%@page import="cfs.databean.Fund"%>
<jsp:include page="tempHeader.jsp" />
<jsp:include page="tempMenubar.jsp" />
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="cfs.databean.Customer" %>
<form method="post" action="transitionFund.do">
    
<div id="container">
    <div id="content" class="wrap">  
          <hr><h2>Transition Day</h2>
            <%
                String globalDate = (String) request.getAttribute("latestDate");
            %>
       
          <h3> Latest Transaction Date: <%= globalDate %></h3>
          <h3>Input Next Transaction Date: Transaction Date:</h3>              
          <input type="text" value="${nextDay}" name="dateInput"/>
          <i>*input format: yyyy/mm/dd</i>
          
          <p><jsp:include page="error-list.jsp" /></p>
    </div>
   
</div>
<hr><div id="container">
        <div id="content" class="wrap">                
                        <h3>Current Registered Funds</h3>
                        <br/>
                            <table>
                                <thead style="text-align: left;">
                                <tr>
				<th class="header" width ="200" style="text-align:left;"><span class="under"><a href="#"
						title="Sort by Type" tabindex="65">Fund Name</a></span></th>
                                <th class="header" width ="100" style="text-align:left;"><span class="under"><a href="#"
						title="Sort by Type" tabindex="65">Symbol</a></span></th>
                                <th class="header" width ="200" style="text-align: right;"><span class="under"><a href="#"
						title="Sort by Type" tabindex="65">Latest Price</a></span></th>
                                <th class="header" width ="200" style="text-align: right;"><span class="under"><a href="#"
						title="Sort by Type" tabindex="65">Lastest Transition Date</a></span></th>
			        <th class="header" width ="200" style="text-align: right;"><span class="under"><a href="#"
						title="Sort by Type" tabindex="65">New Fund Value</a></span></th>
			        </tr>
                            </thead>   
                <% 
                    Fund[] fundList = (Fund[]) request.getAttribute("fundList");
                    HashMap valueMap = (HashMap) request.getAttribute("valueList");
                    ArrayList<FundPriceHistory> fundPrice = (ArrayList<FundPriceHistory>) request.getAttribute("fundPriceHistory");
                    if(fundList !=null && valueMap != null && fundPrice != null){
                        for(int z=0;z<fundList.length;z++){
                            Fund fund = fundList[z];
                            Object value = (Object) valueMap.get(fund.getFund_id());
                            String latestDate = "Not Initiated Yet";
                            String latestPrice = "Not Initiated Yet";
                            for(int y=0;y<fundPrice.size();y++){
                                if(fundPrice.get(y).getFund_id() == fund.getFund_id()){
                                    latestPrice = fundPrice.get(y).formatDecimal(fundPrice.get(y).getPrice());
                                    latestDate = fundPrice.get(y).formatDate(fundPrice.get(y).getPrice_date());
                                }
                            }
       %>
                             <tr>                         
                                <td><%= fund.getName()%></td>
                                <td><%=fund.getSymbol() %></td>
                                <td style="text-align:right;">&#36;<%= latestPrice %></td>
                                <td style="text-align:right;"><%= latestDate %></td>
                                <td style="text-align:right;"><input type="hidden" value="<%= fund.getFund_id() %>" name="fundID<%=fund.getFund_id()%>"/>
                                <input maxlength="15" type="text" value="<%= value %>" name="value<%=fund.getFund_id()%>"/>
                                </td>
                                </tr>
                <%
                    }
                  }
                %>
                            </table>
                        <div id="contact_form">
                            <input type="hidden" value="submitIn" name="requestedSubmit"/>
                            <input type="submit" class="submit_btn" name="submit" id="submit" value="Submit" />
                      
                        </div>
                    
                </div>  
    </div>
     </form>
<jsp:include page="tempBottom.jsp" />